package com.example.ttt.functions;

import com.example.ttt.jcomp.JFrameComponent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.swing.*;

/*
* 暂停和恢复播放事件
* */

@Component
@Slf4j
public class Button_StartOrStop {

    @Autowired
    private JFrameComponent jFrameComponent;

    //播放暂停响应事件
    public void stopOrStart(){
        /*
        * 获取Juke对象
        * 判断当前的恢复和暂停状态
        * 调用juke的copyResume，copyPause进行相关操作
        * */
        JLabel playerStop = jFrameComponent.getPlayerStop();
        JukeCopy jukeCopy = jFrameComponent.getJukeCopy();

        Integer playStatus = jFrameComponent.getPlayStatus();
        if (playStatus == 2){
            // 暂停
            jukeCopy.copyPause();
        }else if (playStatus == 1){
            // 恢复
            jukeCopy.copyResume();
        }else {
            log.info("操作失败，播放状态不正确");
        }
    }
}
